class IPerson{
public:
virtual ~IPerson();
virtual std::string name() const=0;
virtual std::string birthDate() const=0;
};
std::shared_ptr<IPerson> makePerson(DatabaseID personIdentifier);
DatabaseID id(askUserForDatabaseID();
std::shared_ptr<IPerson> pp(makePerson(id));
class PersonInfo{
public:
explicit PersonInfo(DatabaseID pid);
virtual ~PersonInfo();
virtual const char* theName() const;
virtual const char* theBirthDate() const;
private:
virtual const char* valueDelimOpen() const;
virtual const char* valueDelimClose() const;
};
const char* PersonInfo::valueDelimOpen() const{
return "[";
}
const char* PersonInfo::valueDelimClose() const{
return "]";
}
const char* Personinfo::name() const{
static char value[MAX_Formatted_Field_Value_Length];
std::strcpy(value, valueDelimOpen());
std::strcat(value, valueDelimClose());
return value;
}
class CPerson: public IPerson, private PersonInfo{
public:
explicit CPerson(DatabaseID pid): PersonInfo(pid) {}
virtual std::string name() const{
return PersonInfo::theName();
}
virtual std::string birthDate() const{
return PersonInfo::theBirtheDate();
}
private:
const char* valueDelimOpen() const{ return ""; }
const char* valueDelimOpen() const{ return ""; }
}